package com.chinasoftware.civilaviation.service.Impl;

import com.chinasoftware.civilaviation.entity.Admin;
import com.chinasoftware.civilaviation.entity.AdminExample;
import com.chinasoftware.civilaviation.mapper.AdminMapper;
import com.chinasoftware.civilaviation.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

	@Autowired
	private AdminMapper adminMapper;

	@Override
	public Admin findByAnameAndPassword(String aname, String password) {
		AdminExample ae = new AdminExample();
		ae.createCriteria().andAnameEqualTo(aname).andPasswordEqualTo(password);
		List<Admin> admins = adminMapper.selectByExample(ae);
		if(admins.size()!=1) {
			return null;
		}else {
			return admins.get(0);
		}
	}

}
